package main

import (
	"fmt"
	"math/rand"
	"time"
)

func sayHello(ch chan int) {
	sleepTime := rand.Int63n(10)
	fmt.Println("我要睡上几秒呢？", sleepTime)
	time.Sleep(time.Second * time.Duration(sleepTime))
	ch <- int(sleepTime)

}
func main() {
	rand.Seed(time.Now().UnixNano())
	var signal = make(chan int)
	go sayHello(signal)

	select {
	case n := <-signal:
		fmt.Println(n)
	case <-time.After(4 * time.Second):
		fmt.Println("我已经等了你四秒钟了，我走了！！！！！！")
	}

}
